package com.bjpowernode.services;

import com.bjpowernode.beans.Remark;
import com.bjpowernode.mapper.RemarkMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;


@Service
public class RemarkServicesImp implements RemarkServices {


    @Autowired
    RemarkMapper remarkMapper;


    @Override
    public boolean add(Remark remark) {
        remark.setId(UUID.randomUUID().toString().replace("-", ""));
        remark.setNoteTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        return remarkMapper.add(remark) > 0 ? true : false;
    }

    @Override
    public boolean del(String id) {
        return remarkMapper.del(id) > 0 ? true : false;
    }

    @Override
    public Remark get(String id) {
        return remarkMapper.get(id);
    }

    @Override
    public boolean edit(Remark remark) {
        remark.setEditFlag("1");
        remark.setEditTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        return remarkMapper.edit(remark) > 0 ? true : false;
    }
}
